<template>
  <div class="app-main-container">
    <div class="goback" @click="goBack">
      <i class="el-icon-refresh-left" /> 返回上一页
    </div>
    <el-form v-if="activeTab == 1" ref="form" class="doumee-form" :model="param">
      <!-- <el-form-item style="margin-bottom: 10px;">
        <h1 class="title">{{ param.title }}</h1>
      </el-form-item>
      <el-form-item style="margin-bottom: 10px;">
        <p class="sendtime">发布时间：{{ param.sendTime }}</p>
      </el-form-item>
      <el-form-item>
        <p class="content">{{ param.content || '' }}</p>
      </el-form-item> -->
      <h1 class="title" style="margin-bottom: 20px;">{{ param.title }}</h1>
      <!-- <p class="sendtime" style="margin-bottom: 20px;">发布时间：{{ param.sendTime }}</p> -->
      <p class="sendtime" style="margin-bottom: 20px;">发布时间：{{ param.publishTime }}</p>
      <p class="content">{{ param.content || '' }}</p>
      <p v-if="param.filePath" class="sendtime"><a :href="param.filePath" target="_blank">附件</a></p>
    </el-form>
    <el-form v-else ref="form" class="doumee-form" :model="param">
      <h1 class="title" style="margin-bottom: 20px;">{{ param.title }}</h1>
      <p class="sendtime" style="margin-bottom: 20px;">发布时间：{{ param.publishTime }}</p>
      <p class="content" style="margin-bottom: 20px;">{{ param.content || '' }}</p>
      <p v-if="param.filePath" class="sendtime"><a :href="param.filePath" target="_blank">附件</a></p>
    </el-form>
  </div>
</template>

<script>
import { noticeDetail, noticeList, noticeDetailb } from '@/api'
export default {
  data() {
    return {
      activeTab: '',
      param: {}
    }
  },
  mounted() {
    this.activeTab = this.$route.query.activeTab
    this.getDetailInfo()
  },
  methods: {
    // 返回上一页
    goBack() {
      this.$router.go(-1)
    },
    getDetailInfo() {
      if (this.$route.query.activeTab === '1') {
        noticeDetailb({
          param: {
            id: this.$route.query.id
          }
        })
          .then((res) => {
            if (res.errorCode !== '000000') return
            this.param = res.record
          })
          .catch
      } else {
        noticeDetail({
          param: {
            id: this.$route.query.id
          }
        })
          .then((res) => {
            if (res.errorCode !== '000000') return
            this.param = res.record
            this.getList()
          })
          .catch(() => {
          })
      }
    },
    getList() {
      noticeList({
        param: {
          venueId: sessionStorage.getItem('venueId'),
          status: '0'
        }
      })
        .then((res) => {
          if (res.errorCode !== '000000') return
          let num = res.totalCount
          if (num && num > 99) {
            num = 99
          }
          this.$store.dispatch('app/toSetNoticeNum', num)
        })
    }
  }
}
</script>

<style lang="scss" scoped>
@import "@/styles/variables.scss";

.goback {
  font-size: 12px;
  color: $menuChildActive;
  padding: 0 15px;
  height: 28px;
  width: 110px;
  line-height: 28px;
  margin-left: 24px;
  border-radius: 14px;
  border: 1px solid;
  cursor: pointer;
  &:hover {
    background-color: $menuChildActive;
    color: #fff;
  }
}
.title {
  margin-left: 25px;
  margin-right: 25px;
  margin-bottom: 0;
  font: medium 30px #222;
}
.sendtime {
  margin-top: 0;
  margin-left: 25px;
  margin-right: 25px;
  color: #999;
  font: 14px;
}
.content {
  margin-left: 25px;
  margin-right: 25px;
  color: #333;
  font: 15px;
}
</style>
